using UnityEngine;

public class LoadData
{
	private static bool isLoaded = false;

	public static TeamData[] teamDatas = new TeamData[39];

	public static int[] numberTextureIndex = new int[54];

	public static float[] numberOffsetX = new float[54];

	public static float[] numberOffsetY = new float[54];

	public static float[] numberMirrorOffsetX = new float[54];

	public static float[] numberMirrorOffsetY = new float[54];

	public static float[][] AI_Offense = new float[4][];

	public static float[][] AI_Control = new float[4][];

	public static float[][] AI_Balance = new float[4][];

	public static int[,] levelDatas = new int[40, 6];

	public static int[] levelTeams = new int[40];

	public static void LoadDataInResource()
	{
		if (!isLoaded)
		{
			isLoaded = true;
			MyScreen.init();
			load_Teamdata();
			loadAIData();
			load_Leveldata();
			loadNumberLocation();
			GameData.load();
		}
	}

	private static void load_Teamdata()
	{
		TextAsset textAsset = Resources.Load("Team", typeof(TextAsset)) as TextAsset;

		string[] array = textAsset.text.Split("\n"[0]);
		int num = array.Length - 1;
		if (num <= 0)
		{
			array = textAsset.text.Split("\r"[0]);
			num = array.Length - 1;
		}
		string[][] array2 = new string[num][];
		for (int i = 0; i < num - 1; i++)
		{
			teamDatas[i] = new TeamData();
			array2[i] = array[i + 1].Split(',');
			teamDatas[i].data_number = int.Parse(array2[i][0]);
			teamDatas[i].data_name = array2[i][1];
			teamDatas[i].data_name_abbr = array2[i][2];
			teamDatas[i].data_rate = array2[i][3];
			teamDatas[i].data_location = array2[i][4];
			teamDatas[i].data_point1 = int.Parse(array2[i][6]);
			teamDatas[i].data_point2 = int.Parse(array2[i][7]);
			teamDatas[i].data_point3 = int.Parse(array2[i][8]);
			teamDatas[i].data_pass = int.Parse(array2[i][9]);
			teamDatas[i].data_speed = int.Parse(array2[i][10]);
			teamDatas[i].data_rebound = int.Parse(array2[i][11]);
			teamDatas[i].data_steal = int.Parse(array2[i][12]);
			teamDatas[i].data_block = int.Parse(array2[i][13]);
			teamDatas[i].data_physical = int.Parse(array2[i][14]);
			for (int j = 15; j < 20; j++)
			{
				teamDatas[i].data_player_number[j - 15] = int.Parse(array2[i][j]);
			}
			for (int k = 20; k < 25; k++)
			{
				teamDatas[i].data_player_hair[k - 20] = int.Parse(array2[i][k]);
			}
			for (int l = 25; l < 30; l++)
			{
				teamDatas[i].data_player_skin[l - 25] = int.Parse(array2[i][l]);
			}
			for (int m = 30; m < 35; m++)
			{
				teamDatas[i].data_player_height[m - 30] = int.Parse(array2[i][m]);
			}
			teamDatas[i].data_star = int.Parse(array2[i][35]);
			teamDatas[i].data_type = int.Parse(array2[i][36]);
		}
	}

	private static void loadNumberLocation()
	{
		TextAsset textAsset = Resources.Load("NumberLocation", typeof(TextAsset)) as TextAsset;
		string[] array = textAsset.text.Split("\n"[0]);
		int num = array.Length - 1;
		if (num <= 0)
		{
			array = textAsset.text.Split("\r"[0]);
			num = array.Length - 1;
		}
		string[][] array2 = new string[num][];
		for (int i = 0; i < 54; i++)
		{
			array2[i] = array[i + 1].Split(',');
			numberTextureIndex[i] = int.Parse(array2[i][3]);
			numberOffsetX[i] = float.Parse(array2[i][1]);
			numberOffsetY[i] = float.Parse(array2[i][2]);
			numberMirrorOffsetX[i] = float.Parse(array2[i][4]);
			numberMirrorOffsetY[i] = float.Parse(array2[i][5]);
		}
	}

	private static void loadAIData()
	{
		TextAsset textAsset = Resources.Load("AIOffense", typeof(TextAsset)) as TextAsset;
		TextAsset textAsset2 = Resources.Load("AIControl", typeof(TextAsset)) as TextAsset;
		TextAsset textAsset3 = Resources.Load("AIBalance", typeof(TextAsset)) as TextAsset;
		string[] array = textAsset.text.Split("\n"[0]);
		string[] array2 = textAsset2.text.Split("\n"[0]);
		string[] array3 = textAsset3.text.Split("\n"[0]);
		int num = array.Length - 1;
		int num2 = array2.Length - 1;
		int num3 = array3.Length - 1;
		if (num <= 0)
		{
			array = textAsset.text.Split("\r"[0]);
			num = array.Length - 1;
		}
		if (num2 <= 0)
		{
			array2 = textAsset2.text.Split("\r"[0]);
			num2 = array2.Length - 1;
		}
		if (num3 <= 0)
		{
			array3 = textAsset3.text.Split("\r"[0]);
			num3 = array3.Length - 1;
		}
		string[][] array4 = new string[num][];
		string[][] array5 = new string[num2][];
		string[][] array6 = new string[num3][];
		for (int i = 0; i < 4; i++)
		{
			AI_Offense[i] = new float[34];
			AI_Control[i] = new float[34];
			AI_Balance[i] = new float[34];
		}
		for (int j = 0; j < 34; j++)
		{
			array4[j] = array[j + 1].Split(',');
			array5[j] = array2[j + 1].Split(',');
			array6[j] = array3[j + 1].Split(',');
			for (int k = 0; k < 4; k++)
			{
				AI_Offense[k][j] = float.Parse(array4[j][k + 1]);
				AI_Control[k][j] = float.Parse(array5[j][k + 1]);
				AI_Balance[k][j] = float.Parse(array6[j][k + 1]);
			}
		}
	}

	private static void load_Leveldata()
	{
		TextAsset textAsset = Resources.Load("Level", typeof(TextAsset)) as TextAsset;
		string[] array = textAsset.text.Split("\n"[0]);
		int num = array.Length - 1;
		if (num <= 0)
		{
			array = textAsset.text.Split("\r"[0]);
			num = array.Length - 1;
		}
		string[][] array2 = new string[num][];
		for (int i = 0; i < num - 1; i++)
		{
			array2[i] = array[i + 1].Split(',');
			levelTeams[i] = int.Parse(array2[i][0]);
			levelDatas[i, 0] = int.Parse(array2[i][1]);
			levelDatas[i, 1] = int.Parse(array2[i][2]);
			levelDatas[i, 2] = int.Parse(array2[i][3]);
			levelDatas[i, 3] = int.Parse(array2[i][4]);
			levelDatas[i, 4] = int.Parse(array2[i][5]);
			levelDatas[i, 5] = int.Parse(array2[i][6]);
		}
	}
}
